<!--一本二手书信息-->
<ion-view ng-controller="ion_book_oneUsedBook" view-title="{{title}}">
    <ion-nav-buttons side="right">
        <button class="button button-clear button-balanced" ui-sref="book.search-list">寻书</button>
    </ion-nav-buttons>
    <ion-content>
        <div class="list">
            <!-- 图书基本信息-->
            <ion-one-book-info ng-if="usedBook" book-info="usedBook.attributes.bookInfo"
                               should-show-used-books-count="true"></ion-one-book-info>
            <!-- 旧书信息-->
            <ion-item>
                <h3 ng-bind="title"></h3>

                <h3 ng-if="usedBook.attributes.price>0">
                    <span ng-if="usedBook.attributes.role==='sell'">主人要价:</span>
                    <span ng-if="usedBook.attributes.role==='need'">最高承受:</span>
                    <strong ng-bind="usedBook.attributes.price"></strong>
                </h3>

                <p>时间:<strong ng-bind="usedBook.updatedAt | date:'mediumDate'"></strong></p>

                <p ng-if="usedBook.attributes.des">主人描述:
                    <strong style="white-space: pre-wrap" ng-bind="usedBook.attributes.des"></strong>
                </p>
            </ion-item>
            <!-- 如果是主人本人就显示管理按钮-->
            <ion-item ng-if="isMy()">
                <button class="button button-small button-outline button-calm"
                        ng-if="usedBook.attributes.alive"
                        ng-click="UsedBook$.killUsedBook(usedBook)">
                    <span ng-if="usedBook.attributes.role==='sell'">已卖</span>
                    <span ng-if="usedBook.attributes.role==='need'">已买</span>
                    <span ng-if="usedBook.attributes.role==='circle'">已送</span>
                </button>
                <button class="button button-small button-outline button-calm"
                        ng-if="!usedBook.attributes.alive"
                        ng-click="UsedBook$.backToLifeUsedBook(usedBook)">
                    <span ng-if="usedBook.attributes.role==='sell'">撤销已卖</span>
                    <span ng-if="usedBook.attributes.role==='need'">撤销已买</span>
                    <span ng-if="usedBook.attributes.role==='circle'">撤销已送</span>
                </button>
                <button class="button button-small button-outline button-balanced"
                        ui-sref="person.edit-one-used-book({usedBookId:usedBook.id})">修改
                </button>
            </ion-item>
        </div>
        <!-- 主人信息-->
        <div ng-if="!isMy()" class="list">
            <ion-item class="item-divider item-button-right">主人信息
                <a class="button button-clear button-balanced"
                   ui-sref="person.send-msg-to-user({receiverObjectId:usedBook.attributes.owner.id,usedBookObjectId:usedBook.id,role:'buy',inboxType:'private'})">私信Ta
                </a>
            </ion-item>
            <ion-user-info user="usedBook.attributes.owner" used-book-object-id="usedBook.id"></ion-user-info>
            <ion-item>
                <button ng-if="usedBook.attributes.role ==='sell'"
                        class="button button-block button-small button-balanced"
                        ng-click="Status$.requestSellUsedBook(usedBook,$event)">我买了,向Ta预定
                </button>
                <button ng-if="usedBook.attributes.role ==='need'"
                        class="button button-block button-small button-balanced"
                        ng-click="Status$.requestNeedUsedBook(usedBook,$event)">我正好有,卖给Ta
                </button>
                <button ng-if="usedBook.attributes.role ==='circle'"
                        class="button button-block button-small button-balanced"
                        ng-click="Status$.requestCircleUsedBook(usedBook,$event)">我想要,向Ta索要
                </button>
            </ion-item>
        </div>

        <!-- 用户评论-->
        <div class="list">
            <ion-item class="item-divider item-button-right">大家都说
                <a class="button button-clear button-balanced"
                   ui-sref="person.send-msg-to-user({receiverObjectId:usedBook.attributes.owner.id,usedBookObjectId:usedBook.id,role:'buy',inboxType:'reviewUsedBook'})">发表评论
                </a>
            </ion-item>
            <ion-item ng-if="statusList.length==0">还没有同学评论,快来抢沙发~</ion-item>
            <ion-item class="item-avatar" ng-repeat="status in statusList">
                <img ng-src="{{status.attributes.source.avatarUrlWithSize(64)}}"
                     ui-sref="common.user-home({ownerId:status.attributes.source.id})">

                <h2 style="white-space: pre-wrap" ng-bind="status.attributes.message"></h2>

                <p>{{status.updatedAt | date:'mediumDate'}}</p>
                <img style="width: 40px;height: 40px;position: absolute;top: 16px;right: 16px;border-radius: 50%;"
                     ui-sref="common.user-home({ownerId:status.attributes.to.id})"
                     ng-src="{{status.attributes.to.avatarUrlWithSize(64)}}">
            </ion-item>
        </div>
    </ion-content>
</ion-view>